package com.example.tests;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import java.util.Random;

import java.util.Set;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class GroupRemovalTests extends TestBase {

	Random rnd = new Random();
	
	@DataProvider(name = "removeAnyGroups")
	public Iterator<Object[]> deleteRandomGroup() {
		Set<GroupObject> groups = app.getGroupHelper().getGroups();
		GroupObject anyGroup = groups.iterator().next();

		List<Object[]> list = new ArrayList<Object[]>();

		list.add(new Object[]{anyGroup});
		return list.iterator();

	}
	
	@Test(dataProvider = "removeAnyGroups")
	public void testValidGroupCanBeRemoved(GroupObject anyGroup) throws Exception {
		Set<GroupObject> oldList = app.getGroupHelper().getGroups();
		for (int j=0; j<17; j++) {
		app.getGroupHelper().deleteGroup(anyGroup);
		}
		Set<GroupObject> newList = app.getGroupHelper().getGroups();
		//validate
		verifyGroupRemoved(oldList, anyGroup, newList);
	}
}
